package Color;

public class TextPaper implements Paper {
    private int charPerLine = 16;
    private int linePerPapg = 5;
    private String content = "";
    private int posX = 0;
    private int posy = 0;
    private int posP = 1;

    @Override
    public String getContent() {
        String ret = this.content;
        if (!(posX == 0 && posy == 0)) {
            int count = linePerPapg - posy;
            for (int i = 0; i < count; i++) {
                ret += Paper.newline;
            }
            ret += "==第" + posP + "页==";
        }
        return ret;
    }

    @Override
    public void putInChar(char c) {
        content += c;
        ++posX;
        if (posy == linePerPapg) {
            content += "==第" + posP + "页==";
            content += Paper.newline + Paper.newline;
            posy = 0;
            ++posP;
        }
    }

    public void setCharPerLine(int charPerLine) {
        this.charPerLine = charPerLine;
    }

    public void setLinePerPapg(int linePerPapg) {
        this.linePerPapg = linePerPapg;
    }
}
